<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 234px;
            height: 150px;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -150px;
            margin-top: -150px;
            border: 1px solid #CCC;
            border-radius: 10px;
            padding: 50px;
            line-height: 40px;
            background: pink;
        }

        .tipbox{
            position:absolute;
            top: 136px;
            color: red;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <h3>注册页</h3>
    <div class="box">
        <form action="/register" method="post">
            <label for="name">账号：</label><input type="text" name="username" id="name"><br />
            <label for="pwd">密码：</label><input type="password" name="pwd" id="pwd"><br />
            <label for="pwd2">确密：</label><input type="password" name="pwd2" id="pwd2"><br />
            <p class="tipbox"></p>
            <button disabled>注册</button>
        </form>
    </div>
    <script>
        let form = document.querySelector('form');
        let inp = document.querySelectorAll('input');
        let btn = document.querySelector('button');
        let tipbox = document.querySelector('.tipbox');

        inp[2].onblur = function(){
            if(inp[1].value === inp[2].value){
                btn.disabled = false;
                tipbox.innerHTML = ''
            }else{
                btn.disabled = true;
                tipbox.innerHTML = '请输入正确的确认密码'
            }
        }
       


    </script>
</body>
</html>